package com.wlyuan.open.scanner.application.handler.full;

import com.wlyuan.open.dto.OpenVehicleSyncDTO;
import com.wlyuan.open.scanner.application.annotation.ScannerCode;
import com.wlyuan.open.scanner.assembler.ScannerVehicleAssembler;
import com.wlyuan.open.scanner.constant.ScannerCodeEnum;
import com.wlyuan.open.scanner.domain.vehicle.Vehicle;
import com.wlyuan.open.scanner.repository.CarRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lijing
 * @description
 */
@ScannerCode(code = ScannerCodeEnum.VEHICLE)
@Service
@Slf4j
@RequiredArgsConstructor
public class ScannerVehicleHandler extends BaseScannerHandler<Vehicle, OpenVehicleSyncDTO> {

    private final CarRepository carRepository;

    @Override
    protected List<Vehicle> select() {
        return carRepository.list();
    }

    @Override
    protected List<OpenVehicleSyncDTO> assembler(List<Vehicle> data) {
        return ScannerVehicleAssembler.assemble(data);
    }

}
